package com.ming.mapper;

import com.ming.pojo.entity.EmpExpr;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpExprMapper {

    @Select("SELECT * FROM emp_expr WHERE emp_id = #{empId} ORDER BY begin DESC")
    List<EmpExpr> getByEmpId(Integer empId);

    @Insert("INSERT INTO emp_expr(emp_id, begin, end, company, job) VALUES (#{empId}, #{begin}, #{end}, #{company}, #{job})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(EmpExpr empExpr);

    @Update("UPDATE emp_expr SET begin = #{begin}, end = #{end}, company = #{company}, job = #{job} WHERE id = #{id}")
    void update(EmpExpr empExpr);

    @Delete("DELETE FROM emp_expr WHERE id = #{id}")
    void deleteById(Integer id);

    @Delete("DELETE FROM emp_expr WHERE emp_id = #{empId}")
    void deleteByEmpId(Integer empId);

    void insertBatch(@Param("list") List<EmpExpr> empExprList);
}